/**
 * 
 */
package IC.asm.RegAllocation;

import java.util.ArrayList;
import java.util.List;

import IC.asm.ASMEntry;
import IC.asm.decl.CommentEntry;
import IC.asm.Instruction;
import IC.asm.Visitor;
import IC.asm.decl.ASMDecl;
import IC.asm.decl.IntDecl;
import IC.asm.decl.LabelDecl;
import IC.asm.decl.SectionDecl;
import IC.asm.decl.StringDecl;
import IC.asm.operands.*;


public abstract class DefaultAllocator<D,U> implements Visitor<D,U> {

	// output code
	protected static List<ASMEntry> code = new ArrayList<ASMEntry>();
	
	public U addCode(ASMEntry e) {
		code.add(e);
		return null;
	}

	public U visit(LabelDecl that, D d) {
		return addCode(that);
	}

	public U visit(StringDecl that, D d) {
		return addCode(that);
	}

	public U visit(IntDecl that, D d) {
		return addCode(that);
	}

	public U visit(SectionDecl that, D d) {
		return addCode(that);
	}
	
	public U visit(ASMDecl that, D d) {
		return addCode(that);
	}


	public U visit(Instruction that, D d) {
		return addCode(that);
	}

	public U visit(IntImmediate that, D d) {
		return (U)that;
	}

	public U visit(MachineReg that, D d) {
		return (U)that;
	}

	public U visit(VirtualReg that, D d) {
		return (U)that;
	}


	public U visit(Label that, D d) {
		return (U)that;
	}

	public U visit(MemOperand that, D d) {
		return (U)that;
	}

	public U visit(CommentEntry that, D d) {
		return addCode(that);
	}

}
